import { _decorator, AudioClip, Component, Layers, log, Node, resources, sp, SpriteFrame, UI } from 'cc';
import { BaseScene } from '../utils/BaseScene';
import { AudioManager } from '../managers/AudioManager';
import { UserDate } from '../global/UserDate';
import { GlobalManager } from '../global/GlobalManager';
import { GlobalRoot } from '../global/GlobalRoot';
import { ResourceManager } from '../managers/ResourceManager';
import { Sprite, director, EventKeyboard, KeyCode, input, Input, instantiate, Label } from 'cc';
import { GameFeatureTest } from '../alltests/GameFeatureTest';
import { GlobalUIManager } from '../global/GlobalUIManager';
const { ccclass, property } = _decorator;

@ccclass('MainScript')
export class MainScript extends BaseScene {
  
    start() {
        input.on(Input.EventType.KEY_DOWN, this.onKeyDown, this);

        AudioManager.getInstance().setEffectVolume(UserDate.getInstance().SoundVolume)
        AudioManager.getInstance().setEffectVolume(UserDate.getInstance().MusicVolume)
        AudioManager.getInstance().playMusic("Flk_bgmusic", true, true)
    }

    onDestroy() {
        input.off(Input.EventType.KEY_DOWN, this.onKeyDown, this);
    }

    showTest = true
    private onKeyDown(event: EventKeyboard) {
        log("event.keyCode=======",event.keyCode)
        if (event.keyCode === KeyCode.KEY_T) {
            this.showTest? GlobalRoot.instance.UiManager.showPopup(GlobalManager.popups.testPop): GlobalRoot.instance.UiManager.closePopup(GlobalManager.popups.testPop)
            this.showTest = ! this.showTest
            
        } 
        
    }

    

    /**打开设置 */
    openSetting() {
        AudioManager.getInstance().playSound("Flk_zhuandong", true)
        GlobalRoot.instance.UiManager.showPopup(GlobalManager.popups.settingPop)
    }

    /**打开设置 */
    openRank() {

        AudioManager.getInstance().playSound("click",)

        GlobalRoot.instance.UiManager.showPopup(GlobalManager.popups.rankPop)
    }



    update(deltaTime: number) {

    }
}


